<?php
	$ar = $this->get("post");
?>
<form method="post" action="<?php _e(actionUrl($this))?>" onsubmit="return ajax_form(this)" id="task-form" enctype="multipart/form-data">
<input type="hidden" name="ID" value="<?php _e($post['ID'])?>"/>

<div class="x-list-title">
		<table width="100%" border="0" height="100%">
			<tr>
				<td align="left">
					<h2>Chi tiết công văn đến số <?php _e($ar['code'])?>
					</h2>
				</td>
				<td align="right">	
					<div class="x-list-options">
						<?php if($ar['decided']!='yes'){?>
						<a class="x-button" href="#Diploma/Index/decide?ID=<?php _e($ar['ID']);?>">Phê duyệt</a>
						<?php }else{?>
						<a class="x-button" href="#Diploma/Index/decide?ID=<?php _e($ar['ID']);?>">Bỏ duyệt</a>
						<?php }?>
						<a class="x-button" onclick="load_inframe('<?php _baseUrl();?>/Diploma/Index/comment?ID=<?php _e($ar['ID']);?>',{title: 'Ý kiến phê duyệt',css_content:{width:'450px'},auto_hidden: true })">Chỉ đạo / Thảo luận</a>
						<div class="x-options-container">
						
							<a class="x-button"> Tác vụ khác <span>&#9660;</span></a>
							<div class="x-options">
							
								<?php if($this->get('user_id')==$ar['created_by_id']){?>
									<a class="x-options-item" href="#Diploma/Index/edit?ID=<?php _e($ar['ID']);?>">Sửa công văn</a>
								<?php }?>
								
								<?php if($this->get('user_id')==$ar['created_by_id']){?>
									<a class="x-options-item" onclick="module_delete('<?php _e(BASE_URL)?>/Diploma/Index/delete?ID=<?php _e($ar['ID']);?>')">Xóa công văn</a>
								<?php }?>
								<a class="x-options-item" onclick="load_inframe('<?php _baseUrl();?>/Diploma/Index/forward?ID=<?php _e($ar['ID']);?>',{title: 'Chọn xử lý',css_content:{width:'500px'},auto_hidden: true })">Chuyển tiếp</a>
								<a class="x-options-item" onclick="window.print();">In công văn</a>
							</div>
						</div>
					</div>
				</td>
			</tr>
			</table>	
		</div>

<div class="x-info">
	<div class="form-message"></div>
	<table width="100%" cellpadding="7" class="x-info">
		<tr>
			<td colspan="4" align="right" class="x-info-top">
				<span class="tl">Thông tin chi tiết</span>
				<span class="tr">Cập nhập lần cuối lúc <?php _e( show_date('H:i:s d-m-Y',$ar['date_updated']) );?>  bởi <a class="userlink username" href="#User/Info?ID=<?php _e($ar['updated_by_id'])?>"> <?php _e( $ar['updated_by_name'] );?></a></span>
			</td>
		</tr>
		<tr>
			<td class="x-info-label" >Loại công văn</td>
			<td class="x-info-content">
				<?php _e($ar['subtype'])?>
			</td>
		
			<td class="x-info-label" >Số hiệu</td>
			<td class="x-info-content"><b style="color:red;"><?php _e($ar['code'])?></b></td>
		</tr>
		<tr>
			<td class="x-info-label" >Ngày phát hành</td>
			<td class="x-info-content"><?php _e(date(DATE_FORMAT,strtotime($ar['date_enactment'])))?></td>
		
			<td class="x-info-label">Ngày đến</td>
			<td class="x-info-content">
				<?php _e(date(DATE_FORMAT,strtotime($ar['date_get'])));?>
			</td>
		</tr>
		<tr>
			<td class="x-info-label">Cơ quan ban hành</td>
			<td class="x-info-content">
				<?php _e($ar["ogran_by"]);?>
			</td>
		
			<td class="x-info-label">Trích yếu</td>
			<td class="x-info-content">
				<?php _e($ar["abstracts"]);?>
			</td>
		</tr>
		<tr>
			
		
			<td class="x-info-label">Danh sách xử lý chính</td>
			<td class="x-info-content">
					<?php $a=array();
						 foreach( $this->get('userProc') as $u ){
								$a[]= get_user_link($u);
						}
						 _e(implode(", ",$a));
						 if(count($a)==0) _e('<i>Không có</i>');
					?>
				
			</td>
			<td class="x-info-label">Người phê duyệt</td>
			<td class="x-info-content">
				<?php $a=array();
				
						 foreach( $this->get('userDec') as $u ){
								$a[]= get_user_link($u);
						}
						 _e(implode(", ",$a));
						 if(count($a)==0) _e('<i>Không có</i>');
				?>
			</td>
		</tr>
		<tr>
			
		
			<td class="x-info-label">Mức độ ưu tiên xử lý</td>
			<td class="x-info-content">
				<?php 
					switch ($ar["prior"]){
						case 1:_e("Thấp");break;
						case 2:_e("<span style='color:#EAD018;'>Bình thường</span>");break;
						case 3:_e("<span style='color:red;'>Cao</span>");break;
						default:_e("<span style='color:#EAD018;'>Bình thường</span>");
					}
				?>
			</td>
			<td class="x-info-label">File đính kèm</td>
			<td class="x-info-content">
				<?php 
					$file = $this->get('files');
					if(count($file)>0){
					foreach($file as $f){?>
					<?php $a=array();?>
					<?php show_thumb( $f, baseUrl()."/Diploma/Index/File?ID={$f['ID']}");?>
					<?php }
					}else{
						_e("<i>Không có file đính kèm.</i>");
					}
				?>
			</td>
		</tr>
		<tr>
			<td class="x-info-label">Ghi chú</td>
			<td class="x-info-content" colspan="3">
				<?php _e($ar["desc"]);?>
			</td>
		</tr>
		<tr>
			<td colspan="4" align="left" class="x-info-top">
					<span class="tl">Ý kiến thảo luận</span>
				<?php if($ar['decided']=='yes'){?>
					<span class="tr">Công văn này đã được phê duyệt lúc <?php _e( show_date('H:i:s d-m-Y',$ar['date_decided']) );?>  bởi <a class="userlink username" href="#User/Info?ID=<?php _e($ar['decided_by_id'])?>"> <?php _e( $ar['decided_by_name'] );?></a></span>
				<?php }?>
			</td>
		</tr>
		<!--COMMENT LIST-->
	<?php if($this->get("comment")!=""){?>
	<?php foreach( $this->get("comment") as $k => $a ){ ?>
	<tr>
		<td class="x-info-comment" align="center">
			<?php if($a['created_by_photo']){?>
			<img class="comment-avatar" src="<?php _baseUrl()?>/files/photo/<?php _e($a['created_by_photo'])?>"/>
			<?php }else{?>
			<img class="comment-avatar" src="<?php _baseUrl()?>/files/photo/noavatar.gif"/>
			<?php }?>
		</td>
		<td valign="top" align="left" colspan="3">
			<div class="comment-bar">
				<span class="comment-copy">Đăng bởi <?php _e(get_user_link($a['created_by_id'],$a['created_by_name'],$a['created_is_deleted']) )?> 
					lúc <?php _e(show_date(TIME_FORMAT,$a['date_created']))?> <?php _e(show_date(DATE_FORMAT,$a['date_created']))?>
				</span>	
				<span class="comment-button">
					<?php if($a['created_by_id']==$this->get('user_id')){?>
					<a onclick="module_delete('<?php _baseUrl($this)?>/Diploma/Index/deletecomment?ID=<?php _e($a['ID']);?>&&diploma_id=<?php _e($_REQUEST['ID'])?>')">Xóa</a> |
					<a onclick="load_inframe('<?php _baseUrl();?>/Diploma/Index/editcomment?ID=<?php _e($a['ID']);?>&&diploma_id=<?php _e($_REQUEST['ID'])?>',{title: 'Sửa',css_content:{width:'450px'},auto_hidden: true })">Sửa</a>
					<?php }?>
				</span>				
			</div>	
			<div class="comment-content">
				<?php _e($a['content']);?>
			</div>
		</td>
	</tr>
	<?php }
	}else{?>
	<tr>
		<td colspan="4"><i>Chưa có ý kiến chỉ đạo nào.</i></td>
		
	</tr>
	<?php }?>
	</table>
</div>
</form>